// 引入path包
const path = require('path')
const { CleanWebpackPlugin } = require('clean-webpack-plugin'); //引入清除文件插件
const { ProvidePlugin } = require('webpack');

module.exports = {
    entry: "./src/main.ts",
    // devtool: 'inline-source-map',
    mode: "production",
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: "main.js"
    },

    plugins: [
        new CleanWebpackPlugin(),
        // new ProvidePlugin({
        //     Promise: "promise",
        //     clearTimeout: path.resolve(__dirname, 'src',"clearTimeout.ts"),
        //     clearInterval: path.resolve(__dirname, 'src',"clearInterval.ts"),
        // })
    ],
    resolve: {
        extensions: ['.tsx', '.ts', '.js']
    },
    module: {
        rules: [
            {
                test: /\.tsx?$/,
                use: 'ts-loader',
                exclude: /node_modules/,
                resolve: {
                    // 关闭fullySpecified
                    fullySpecified: false, // disable the behaviour
                }
            }
        ]
    },
}
